﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ESRI.ArcGIS.Display;
using EAGL.Server;
using EAGL.Core;
using EAGL.Display;
using ESRI.ArcGIS.esriSystem;
using EAGL.Data;
using ESRI.ArcGIS.Geodatabase;


namespace tester
{
    public partial class Form1 : Form
    {
        private ConnectionManager connMan;
        private ContextManager contextMan;

        private const string USER_NAME = "GISAPPSSVC";
        private const string PASSWORD = "GISsvc@2009";
        private const string SERVER_HOST = "mcsgisweb";
        private const string MAP_NAME = "kumait_test";

        ArcGISServerConnectionInfo connInfo;
        
        public Form1()
        {
            InitializeComponent();
        }


        private void initServer()
        {
            SecurityHelper.Init();
            connInfo = new ArcGISServerConnectionInfo(USER_NAME, PASSWORD, SERVER_HOST);
            
            try
            {
                connMan = new ConnectionManager(connInfo);
            }
            catch (Exception ex1)
            {
                throw new Exception("Unable to create ConnectionManager object: " + ex1.Message);
            }
            try
            {
                contextMan = new ContextManager(connMan, MAP_NAME);
            }
            catch (Exception ex2)
            {

                throw new Exception("Unable to create ContextManager object: " + ex2.Message);
            }
        }


        

        private void button1_Click(object sender, EventArgs e)
        {
            SecurityHelper.Init();
            
            WorkspaceInfo inf = new WorkspaceInfo(WorkspaceType.ACCESS);
            inf.Database = @"D:\work\GIS_DATA\KOCData\KOCData.mdb";
            WorkspaceManager man = new WorkspaceManager(inf);
            IWorkspace ws = man.GetWorkspace();
            IFeatureWorkspace fws = (IFeatureWorkspace)ws;
            IFeatureClass fc1 = fws.OpenFeatureClass("src1");
            IFeatureClass fc2 = fws.OpenFeatureClass("src");

             TableSynchronizer sync = new TableSynchronizer((ITable)fc1, (ITable)fc2, "WELL_NAME", "WELL_NAME");
             SyncResult res =  sync.Synchronize();
           


            

            

        }
    }
}
